package per.zzzfwd.douban.crawler;

import java.util.function.Function;

public class Parser {

    public <T> T parse(String text, Function<String, T> action) {
        if (text == null || text.trim().isEmpty()) {
//            throw new ParseException("text为空，无法解析数据");
            return null;
        }

        try {
            return action.apply(text);
        } catch (Exception e) {
            throw new ParseException("解析数据失败", e);
        }
    }
}
